tools: libxl: testidl: initialise the KeyedUnion keyvar before the union
authorIan Campbell <ian.campbell@citrix.com>
Wed, 4 Dec 2013 17:48:56 +0000 (17:48 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 5 Dec 2013 09:25:35 +0000 (09:25 +0000)
This is Coverity CID 1135378 and 1135379.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxl/gentest.py

index 6fab4933d5ca7f0737f131013cf9bc7f3f1b4e5d..722b7f4bdc17cf5e6a0ce33bd86a9328f7b1031e 100644 (file)
@@ -42,6 +42,7 @@ def gen_rand_init(ty, v, indent = "    ", parent = None):
     elif isinstance(ty, idl.KeyedUnion):
         if parent is None:
             raise Exception("KeyedUnion type must have a parent")
+        s += gen_rand_init(ty.keyvar.type, parent + ty.keyvar.name, indent, parent)
         s += "switch (%s) {\n" % (parent + ty.keyvar.name)
         for f in ty.fields:
             (nparent,fexpr) = ty.member(v, f, parent is None)